package com.decade.com.decade.controller;

import com.decade.com.decade.Exception.NullStringException;
import com.decade.com.decade.pojo.ResponseResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;

@RestController
@Validated
public class ArithmeticContollrt {

    @RequestMapping("/doCompute/{n1}/{n2}")
    public ResponseResult doCompute(
            @PathVariable Integer n1,@Pattern(regexp = "^[^0]+[0-9]*$",message = "输入的数字不能等于0 ") @PathVariable String n2){
        Integer result=n1/Integer.valueOf(n2);
//        throws new  NullStringException("");
        ResponseResult r=new ResponseResult("计算结果:"+result);
        r.setData(result);
        return r;
    }
}
